<template>
    <!-- 列表页面 -->
    <div class="tableSample">
        <div class="title">
            <span>导入订单核算信息</span>
        </div>
        <v-excel @importRequest="importRequest"></v-excel>
    </div>
</template>

<script>
import bus from '@/models/bus'
import VExcel from '@/components/base/excel-pub'

export default {
  components: {
    VExcel,
  },
  props: {},
  data() {
    return {
      loading: false,
    }
  },
  computed: {},
  created() {
  },
  methods: {
    async importRequest(obj) {
      if (obj.length === 0) {
        this.$message.error('导入信息为空')
        return false
      }
      const loading = this.$loading({
        lock: true,
        text: '上传中',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)',
      })
      const data = []
      obj.forEach((item) => {
        data.push({
          out_trade_no: item.支付number.substr(1),
          bus_price: item.微信商户平台交易金额.substr(1),
          bus_msg: item.支付状态.substr(1),
        })
      })
      const res = await bus.updateBus({
        excel_data: data,
      })
      if (res.error_code === 0) {
        this.$message.success(`${res.msg}`)
      }
      loading.close()
    },
  },
}
</script>

<style lang="scss" scoped>
    .tableSample {
        padding: 0 0 30px;

        .title {
            height: 59px;
            line-height: 59px;
            color: $parent-title-color;
            font-size: 16px;
            font-weight: 500;
            text-indent: 40px;
            border-bottom: 1px solid #dae1ed;

            .back {
                float: right;
                margin-right: 40px;
                cursor: pointer;
            }
        }
    }
</style>
